<%--
  Created by IntelliJ IDEA.
  User: cos
  Date: 2022/3/10
  Time: 14:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
    <button id="btn1">点击</button>
    <button id="btn2">点击</button>
<script>
    $(function () {
        $("#btn1").click(function () {
            var user={id:1,name:"张三",sex:"男"};
            let userJson = JSON.stringify(user);
            $.ajax({
                type:"post",
                url:"/demo/addUser",
                contentType:"application/json",
                data:JSON.stringify(user),
                success:function (data) {
                    console.log(data);
                }
            })
        })

        $("#btn2").click(function () {
            var userList=[{id:1,name:"张三",sex:"男"},{id:2,name:"李四",sex:"女"},{id:3,name:"王五",sex:"男"}];
            $.ajax({
                type:"post",
                url:"/demo/addUserList",
                contentType: "application/json",
                data: JSON.stringify(userList),
                success:function (data) {
                    console.log(data);
                }

            })
        })


    })

</script>
</body>
</html>
